package collection;

import java.util.ArrayList;
import java.util.List;

public class SudListDemo {
    public static void main(String[] args) {
       /* List<Integer> list=new ArrayList<>();
        for (int i=0;i<10;i++){
            list.add(i*10);
        }
        System.out.println(list);
        List<Integer> subList=list.subList(3,8);
        System.out.println(subList);


        for (int i=0;i<subList.size();i++){
            subList.set(i,subList.get(i)*10);
        }
        System.out.println(subList);
        //注意：对子集的操作就是对原集合对应的元素的操作
        System.out.println(list);

          list.set(3,1000);
        System.out.println(list);
        System.out.println(subList);//原集合数据改变后，子集数据跟着改变


        list.remove(0);
        System.out.println(list);
        //原集合长度修改之后，子集将不能再进行任何操作，操作发生异常，但是可以重新获取子集
         System.out.println(subList);//运行时发生不支持修改异常*/



        List<Integer> ll=new ArrayList<>();
        for (int i=0;i<10;i++){
            ll.add(i*10);
        }
        System.out.println(ll);
        List<Integer> sublist=ll.subList(2,8);
        System.out.println(sublist);
        for (int i=0;i<sublist.size();i++){
            sublist.set(i,sublist.get(i)*10);
        }
        System.out.println(sublist);
        ll.set(3,1000);
        System.out.println(ll);
        System.out.println(sublist);

        sublist.set(4,666);
        System.out.println(ll);
        System.out.println(sublist);

        ll.remove(0);
        System.out.println(ll);
       // System.out.println(sublist);











    }
}
